# -*- coding: utf-8 -*-

from rest_framework import generics
from rest_framework import serializers
from rest_framework.permissions import IsAuthenticated
from rest_framework.renderers import JSONRenderer

from .models import Book
from rest_framework.generics import GenericAPIView,ListCreateAPIView,RetrieveUpdateDestroyAPIView


# def process_response(request, response):
#     # 添加响应头
#     response["Access-Control-Allow-Origin"] = "*"



class SnippetSerializer(serializers.ModelSerializer):
    class Meta:
        model = Book
        fields = '__all__'


class BookListView(generics.ListCreateAPIView):
    queryset = Book.objects.all()
    serializer_class = SnippetSerializer
    # permission_classes = [IsAuthenticated]




class BookUpdateDestroyView(generics.RetrieveUpdateDestroyAPIView):
   queryset = Book.objects.all()
   serializer_class = SnippetSerializer
   # permission_classes = [IsAuthenticated]

